package com.gs.core.service.dao.impl;

import org.hibernate.LockMode;
import org.springframework.stereotype.Component;

import com.gs.core.domain.Person;
import com.gs.core.domain.User;
import com.gs.core.service.dao.GsHibernateDAOFacade;
import com.gs.core.service.dao.GsJdbcDAOFacade;
import com.gs.core.service.dao.PersonDAO;

@Component(value="personJdbcDao")
public class PersonJdbcDAO extends GsJdbcDAOFacade implements PersonDAO{

	public Person save(Person person) {
		String sql = "insert into PERSON (PERSON_TYPE,FIRST_NAME, LAST_NAME,BOSS_ID,DEPT_CODE) values (?,?,?,?,?)";
		User u = (User)person;
		Object params = new Object[] {	
										"USER",
										u.getFirstName(),
										u.getLastName(),
										u.getBoss()==null?null:u.getBoss().getId(),
										u.getDepartmentCode()
										};
		getJdbcTemplate().update(sql, params);
		return person;
	}
	
}
